import projectSetting from '@/config/developers/zhanghanke'

export const URLHEAD = {
      attach: projectSetting.attachUrlHead,
      main: projectSetting.mainUrlHead
}
export const CLOUDSETTING = projectSetting

export const COORD_SYSTEM = 'gcj-02';
export const SYNC_TIME_INTERVAL = 90 * 1000;
export const COLOR_PLATE = ['#7eb6f2', '#e991f2', '#ba8eed', '#5458f3', '#79dbf4', '#79f4ed'];

export const POI_IMAGE_RULE = {
      markerSize: (iconName) => {
            let ratio = JSON.parse(localStorage.ratio);
            if (iconName.includes('construction')) {
                  return {
                        normal: ratio === 2 ? '118,294' : '59,147'
                  }
            } else {
                  return {
                        normal: ratio === 2 ? '120,176' : '60,88'
                  }
            }

      },
      markerImages: (iconName) => {
            let ratio = JSON.parse(localStorage.ratio);
            let afterfix = ratio === 2 ? '2x/' : '';
            return [{
                  define_state: 'normal',
                  normal_url: `${URLHEAD.attach}assets/images/${afterfix}poi-marker-${iconName}.png`,
                  activate_url: `${URLHEAD.attach}assets/images/${afterfix}poi-marker-${iconName}-clicked.png`
            }, {
                  define_state: 'abnormal',
                  normal_url: `${URLHEAD.attach}assets/images/${afterfix}poi-marker-${iconName}-alert.png`,
                  activate_url: `${URLHEAD.attach}assets/images/${afterfix}poi-marker-${iconName}-alert-clicked.png`
            }]
      },
      labelImages: (labelName = 'common') => {
            let key = labelName === null ? 'common' : labelName;
            let keyArray = [];
            let ratio = JSON.parse(localStorage.ratio);
            let afterfix = ratio === 2 ? '2x/' : '';
            if (key.includes('-')) {
                  keyArray = key.split('-')
            }
            const ruleHash = {
                  design: {
                        labelImageFile: `label-header-design.png`,
                        labelSize: ratio === 2 ? `${+keyArray[1]},63` : `${(+keyArray[1]) / 2},31`,
                        labelOffset: ratio === 2 ? '12,266' : '12,133'
                  },
                  common: {
                        labelImageFile: `poi-label-construction.png`,
                        labelSize: ratio === 2 ? '273,63' : '181,31',
                        labelOffset: ratio === 2 ? '12,266' : '12,133'
                  },
                  building: {
                        labelImageFile: `label-header-building.png`,
                        labelSize: ratio === 2 ? `${keyArray[1]},63` : `${(+keyArray[1]) / 2},31`,
                        labelOffset: ratio === 2 ? '12,266' : '12,133'
                  },
                  finished: {
                        labelImageFile: `label-header-finished.png`,
                        labelSize: ratio === 2 ? `${keyArray[1]},63` : `${(+keyArray[i]) / 2},31`,
                        labelOffset: ratio === 2 ? '12,266' : '12,133'
                  }
            }
            if (key.includes('-')) {
                  return {
                        bg_image_url: `${URLHEAD.attach}assets/images/construction/${afterfix}${ruleHash[keyArray[0]].labelImageFile}`,
                        bg_size: ruleHash[keyArray[0]].labelSize,
                        bg_offset: ruleHash[keyArray[0]].labelOffset,
                  }
            }
            return {
                  bg_image_url: `${URLHEAD.attach}assets/images/${ruleHash[keyArray[0]].labelImageFile}`,
                  bg_size: ruleHash[keyArray[0]].labelSize, //label大小(宽, 高 单位:像素)
                  bg_offset: ruleHash[keyArray[0]].labelOffset, //整个label左上角相对于marker的中心点(coord坐标中心点)的偏移(x,y 单位:像素), 注: x为正向右, y为正向上
            }
      }
}

export const SHP_PATH = (fileName) => {
      return `${URLHEAD.attach}assets/shp/${fileName}.shp`
}